package cn.com.nes.site.service.workOrder;

import cn.com.nes.common.web.CommonResult;
import cn.com.nes.mybatis.agent.system.entity.Company;
import cn.com.nes.mybatis.callcenter.entity.WorkOrderInfo;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.entity.bo.workorder.DistributeWorkOrderInstallBO;
import cn.com.nes.site.entity.bo.workorder.GetTeamWorkOrderInstallPageBO;
import cn.com.nes.site.entity.bo.workorder.TransferOrderInstallBO;
import cn.com.nes.site.entity.bo.workorder.WorkOrderBO;
import cn.com.nes.site.entity.dto.workOrder.*;
import cn.com.nes.site.entity.vo.NullVO;
import cn.com.nes.site.entity.vo.project.WorkOrderReviewVo;
import cn.com.nes.site.entity.vo.workOrder.*;
import cn.com.nes.site.service.workOrder.bo.CancelWorkOrdersBO;
import cn.com.nes.site.service.workOrder.bo.CancelWorkOrdersByAreaCodeBO;
import cn.com.nes.site.service.workOrder.bo.CaptainCancelWorkOrdersBO;
import cn.com.nes.site.service.workOrder.dto.CustomerRefusalWorkOrderInfoDTO;
import cn.com.nes.site.service.workOrder.dto.GetWorkOrderInstallPageDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.HashMap;
import java.util.List;
import java.util.Set;

/**
 * 工单业务接口
 */
public interface WorkOrderService extends IService<WorkOrderInfo> {

    /**
     * 单条派发安装工单 - 热链云内部保存
     */
    String distributeWorkOrderInstall(DistributeWorkOrderInstallBO bo) throws Exception;

    /**
     * 在热链云跨库查询全部工单分页接口
     */
    PageData getAllWorkOrderPage(GetAllWorkOrderPageVO vo) throws Exception;

    /**
     * 热链云查询安装工单详情
     */
    PageData getWorkOrderInstallDetail(GetWorkOrderInstallDetailVO vo) throws Exception;

    /**
     * 查询安装工单分页 - 热链云PC端
     */
    PageData getWorkOrderInstallPage(GetWorkOrderInstallPageVO vo) throws Exception;

    /**
     * 约定上门时间
     */
    PageData updateDoorTime(UpdateDoorTimeVo vo);

    /**
     * 安装工单接单
     */
    PageData acceptOrderInstall(AcceptOrderInstallVo vo);

    /**
     * 安装工单签到打卡
     */
    PageData punchClockOrderInstall(AcceptOrderInstallVo vo);

    /**
     * 安装工单拒单
     */
    PageData rejectionOrderInstall(RejectionOrderInstallVo vo) throws Exception;

    /**
     * 单条转单
     */
    PageData transferOrderInstall(TransferOrderInstallVo vo) throws Exception;

    /**
     * 批量转单
     */
    void batchTransferOrderInstall(TransferOrderInstallBO bo) throws Exception;

    /**
     * 安装工单补充房屋信息
     */
    PageData replenishHouseInfo(ReplenishHouseInfoVO vo) throws Exception;

    /**
     * 安装工单补充房屋信息相关下拉框
     */
    PageData replenishHouseDropdownBox(NullVO vo) throws Exception;

    /**
     * 查询当前工单可更换的设备列表 - 下拉框,不分页
     */
    PageData getGoodsList(QueryGoodsListByWorkOrderVO vo) throws Exception;

    /**
     * 安装工单修改产品信息
     */
    PageData updatePriceDetail(UpdatePriceDetailVO vo) throws Exception;

    /**
     * 安装工单修改设备dtu
     */
    void updateInstallEquipment(UpdateInstallEquipmentVO vo) throws Exception;

    /**
     * 更新安装工单施工图片
     */
    PageData updatePicInfo(UpdatePicInfoVO vo) throws Exception;

    /**
     * 完成安装工单
     */
    PageData completeOrderInstall(CompleteOrderInstallVo vo) throws Exception;

    /**
     * 查询安装信息相关下拉框
     */
    PageData getInstallInfoDropdownBox(NullVO vo) throws Exception;

    /**
     * 查询紧急程度下拉框
     */
    PageData getEmergencyDegreeDropdownBox(NullVO vo) throws Exception;

    /**
     * 查询安装工单时间轴
     */
    PageData getWorkOrderInstallTimeAxis(GetWorkOrderInstallDetailVO vo) throws Exception;

    /**
     * 查询安装工单信息
     */
    WorkOrderInfo getWorkOrder(Long saleOrderSystemId);

    /**
     * 查询安装工单信息
     */
    WorkOrderInfo getWorkOrderInfo(Long workOrderId);

    /**
     * 校验客户是否拥有安装工单
     */
    Boolean checkHaveWorkOrder(String customerId);

    /**
     * 查询工单列表
     */
    List<WorkOrderInfo> getWorkOrderList(Long projectId, String areaCode);

    /**
     * 查询客户的拒单情况
     */
    List<CustomerRefusalWorkOrderInfoDTO> getCustomerRefusalWorkOrderInfo(List<String> customerIdList, Set<Long> workOrderIdSet);

    /**
     * 根据项目id查询派单个数
     */
    Integer getDispatchedCount(Long projectId);


    /**
     * 根据项目id查询审核数量
     */

    HashMap<String,Integer> getAuditedCount(Long projectId);

    /**
     * 查询当前客户全部被拒单的工单id
     * @param customerIdList    客户id
     * @param isRefusal     是否被拒单 true-被拒单 false-没拒单
     * @return              工单id列表
     */
    Set<WorkOrderInfo> getWorkOrderInfoSetByCustomerId(List<String> customerIdList, Boolean isRefusal) throws Exception;

    /**
     * 根据派单情况查询客户id列表
     * @param isDispatched 是否已派单 0-未派单 1-已派单 null-全部
     * @return
     */
    List<String> getCustomerIdListByDispatched(Integer isDispatched,Integer audited);

    /**
     * 工头查询施工队安装工单
     */
    Page<GetWorkOrderInstallPageDTO> getMyTeamWorkOrderInstallPage(GetTeamWorkOrderInstallPageBO bo) throws Exception;

    /**
     * 分单
     */
    PageData distributeWorkOrder(EasyRepairDistributeWorkOrderVO vo) throws Exception;

    /**
     * 按行政区划分单
     */
    void distributeWorkOrderByAreaCode(EasyRepairDistributeWorkOrderByAreaCodeVO vo) throws Exception;

    /**
     * 校验接单用户身份
     */
    boolean validateServiceUserAuth(DistributeWorkOrderInstallBO bo) throws Exception;

    /**
     * 审核功能
     */
    PageData workOrderReview(WorkOrderReviewVo vo) throws Exception;

    /**
     * 撤销安装工单
     */
    void cancelWorkOrders(CancelWorkOrdersBO bo) throws Exception;

    /**
     * 根据行政区划代码批量撤销安装工单
     */
    void cancelWorkOrdersByAreaCode(CancelWorkOrdersByAreaCodeBO bo) throws Exception;

    /**
     * 施工队长撤销已分安装工单
     */
    void captainCancelWorkOrders(CaptainCancelWorkOrdersBO bo) throws Exception;

    /**
     * 保存工单
     */
    String saveWorkOrder(WorkOrderBO workOrderBO) throws Exception;

    /**
     * 维修工单
     */
    Long createRepairWorkOrder(WorkOrderBO workOrderBO) throws Exception;
    /**
     * 咨询工单
     */
    Long createConsultWorkOrder(WorkOrderBO workOrderBO) throws Exception;

    Page<SaveWorkOrderByQueryDto> queryCustomerEquipmentList( SaveWorkOrderQueryVo vo) throws Exception;

    GetDeviceDto getDevice(GetDevice vo) throws Exception;
    //查询维修工单
     PageData getRepairWorkOrderPage(GetWorkOrderRepairPageVO vo) throws Exception;

    //查询工单详情
     PageData getWorkOrderRepairDetail(GetWorkOrderRepairDetailVO vo) throws Exception;

    //易修完成维修工单
     PageData completeOrderRepair(CompleteOrderRepairVo vo) throws Exception;


    PageData getSparePart(String companyId)throws Exception;
    PageData getParamsByTypeValue(ParamsVo vo);

    CommonResult<?> evaluationWorkOrder(EvaluationWorkOrderVo vo);

    CommonResult<?> updateWorkOrderStatus(WorkOrderStatusVo vo,String xzqhdms) throws Exception;

    /**
     * 取消工单
     * @param
     * @return
     */
    CommonResult<?> closeWorkOrder(CloseWorkOrderVo vo);

    int auditWorkOrder(AuditWorkOrderVo vo);

    /**
     * 工单回访
     * @param vo
     * @return
     */
    Long workOrderVisit(WorkOrderVisitVo vo);

    /**
     * 查看字典值树结构
     */
    List<ParamTypeDto> getDictionaryTreeValue();

    List<WorkOrderListExportDto> exportWorkOrderInfo(WorkOrderListVo vo);


    int bindCompany(BindCompanyVo vo);

    Page<QueryBindCompanyDto> queryBindCompany(QueryBindCompanyVo vo) throws Exception;

    int unBindCompany(DeleteBindCompanyVo vo);

    Page<Company> getCommissionAgent(GetCommissionAgentVo vo);

    /**
     * 根据处理人id查询行政区划代码集合
     */
    Set<String> getAreaCodeSetByMaintainIds(Set<Long> callCenterUserIdSet);
}
